<div class="Item hr">
    <div class="current">栏目管理</div>
    <div class="fr"><a href="{:U('quick')}" class="btn">批量添加栏目</a></div>
    <div class="fr"><a href="{:U('add')}" class="btn">添加顶级栏目</a></div>
</div>
<form>
    <present name="language">
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab">
        <thead>
            <tr>
                <td width="60">ID</td>
                <td style="text-align:left;">栏目名称</td>
                <td>操作</td>
            </tr>
        </thead>
        <tbody>
        <volist name="list" id="m">
                <php>$pkey = $key;</php>
            <tr>
                <td>栏目语言：</td>
                <td colspan="3" style="text-align:left;">{$m.title} <a href="javascript:;" class="isput teal" data-type='lang{$pkey}' data-show='1'>收起</a></td>
            </tr>
            <volist name="m.cat" id="type" key='j'>
              <eq name="type.reid" value="0">
                <php>$c = $type['id'];</php>
              </eq>
                <tr <eq name="type['ispart']" value="2">bgcolor="#f9fcef"</eq> <gt name="type.reid" value="0"> class="c{$c} hide lang{$pkey}"<else/>class="classp lang{$pkey}"</gt>>
              
                <td align="middle"><label>{$type.id}</label></td>
                <td class="tdleft"><eq name="type.reid" value="0"><span class="icon-plus-sign closec hand" data-class="c{$c}"></span></eq>
                  {$type.fullname}
                  <eq name="type['ishidden']" value="1"><font color='red'>[隐]</font></eq>
                  <neq name="type['lang']" value="">[{$type.lang}]</neq>
                  <eq name="type['ispart']" value="0">(文档：{$type.totalArc})</eq>
                </td>
                <td width="300" style="text-align:right;">
                <a href="{:U('Home/List/index', array('tid' => $type['id']))}" target="_blank">预览</a> | 
                <a href="{:U('add', array('id' => $type['id']))}">添加子栏目</a> | 
                <neq name="type['ispart']" value="2">
                <a href="{:U('Content/index', array('cid' => $type['id']))}">内容</a> | 
                </neq>
                <a href="{:U('edit', array('id' => $type['id']))}">编辑</a> | 
                <a href="javascript:;" class="deleted" data-url="{:U('delete')}" data-id="{$type.id}" data-name="{$type['typename']}">删除</a> 
                <input type="text" value="{$type.sortrank}" class="input" style="width:25px;height:20px; text-align:center;" name="type[sortrank{$type.id}]" />
                </td>
              </tr>
            </volist>
        </volist>
        </tbody>
        <tfoot>
        	<tr>
            	<td colspan="3" align="right"><input type="button" class="btn upRankAll" value="更新排序" /></td>
            </tr>
        </tfoot>
    </table>
    <else/>
    <table width="100%" border="0" cellspacing="0" cellpadding="0" class="tab">
        <thead>
            <tr>
                <td>ID</td>
                <td style="text-align:left;">栏目名称</td>
                <td>操作</td>
            </tr>
        </thead>
        <tbody>
            <volist name="list" id="type">
              <eq name="type.reid" value="0">
                <php>$c = $type['id'];</php>
              </eq>
            <tr align="center">
            <tr <gt name="type.reid" value="0"> class="c{$c} hide"</gt>>
                <td width="50">{$type['id']}</td>
                <td align="left">
                	<eq name="type.reid" value="0"><span class="icon-plus-sign closec hand" data-class="c{$c}"></span></eq>
                    {$type['fullname']}
                  <eq name="type['ishidden']" value="1"><font color='red'>[隐]</font></eq>
                  <eq name="type['ispart']" value="0">(文档：{$type.totalArc})</eq>
                </td>
                <td width="300">[ <a href="{:U('add', array('id' => $type['id']))}">添加子栏目</a> ] [ <a href="{:U('Content/index', array('cid' => $type['id']))}">内容</a> ] [ <a href="{:U('edit', array('id' => $type['id']))}">编辑</a> ] [ <a href="javascript:;" class="deleted" data-url="{:U('delete')}" data-id="{$type.id}" data-name="{$type['typename']}">删除</a> ] <input type="text" value="{$type.sortrank}" class="input" style="width:25px;height:20px; text-align:center;" name="type[sortrank{$type.id}]" /></td>
            </tr>
            </volist>
        </tbody>
        <tfoot>
        	<tr>
            	<td colspan="3" align="right"><input type="button" class="btn upRankAll" value="更新排序" /></td>
            </tr>
        </tfoot>
    </table>
    </present> 
</form>
<script type="text/javascript">
$(function(){
    $(".upRankAll").click(function(){
        commonAjaxSubmit('{:U("upRankAll")}');
        return false;
    });
    $(".deleted").click(function(){
        var url = $(this).data("url");
        var id = $(this).data("id");
        var name = $(this).data("name");

        popup.confirm("您确定删除 <b>" + name + "</b> 及子栏目？", '温馨提示',function(action){
            if(action == 'ok'){
                $.ajax({
					'url' : url,
					'dataType' : 'JSON',
					'type' : 'POST',
					'data' : {'id' : id},
					'success' : function(json){
						if (json.status) {
							popup.success(json.info);
							setTimeout(function(){
								popup.close("asyncbox_success");
							},2000);
		
							setTimeout(function(){
								top.window.location.reload();
							},3000);
						} else {
							popup.error(json.info);
							setTimeout(function(){
								popup.close("asyncbox_error");
							},2000);
						}
					}
				});
            }
        });

        return false;
    });
	$(".isput").on('click', function(){
		var show = $(this).data('show');
		if(show === 1){
			$("."+$(this).data('type')).hide();
			$(this).data('show', 0)
			$(this).text('展开');
		}else{
			$("."+$(this).data('type')).show();	
			$(this).data('show', 1)
			$(this).text('收起');
		}
	});
	$(".closec").on('click', function(){
		var className = $(this).data("class");
		if($(this).hasClass("icon-plus-sign")){
			$(this).addClass("icon-minus-sign").removeClass("icon-plus-sign");
			$("."+className).removeClass("hide").show();
		}else{
			$("."+className).addClass("hide").hide();
			$(this).addClass("icon-plus-sign").removeClass("icon-minus-sign");
		}
	})
});
</script>